﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BookStore.Bussiness;
using BookStore.Data;

namespace BookStore
{
    public partial class Productdetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadProduct();
            }
        }

        public void LoadProduct()
        {

            int ma = Convert.ToInt32(Request.QueryString["productID"]);
            productService biz = new productService();
            DataList1.DataSource = biz.getByIdReturnDataTable(ma);
            DataList1.DataBind();
        }

        protected void lbtback_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void igmbuy_Click(object sender, ImageClickEventArgs e)
        {
            int ma = Convert.ToInt32(Request.QueryString["productID"]);
            productService biz = new productService();
            productInfo sp = biz.getById(ma);
            Cart objCart = new Cart();
            if (Session["cart"] != null)
                objCart = (Cart)Session["cart"];
            objCart.AddToCart(sp);
            Session["cart"] = objCart;
            Response.Redirect("Checkcart.aspx");
        }

        protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            LinkButton lnb = (LinkButton)sender;
            int id = Convert.ToInt32(lnb.CommandArgument);
            productService biz = new productService();
            productInfo sp = biz.getById(id);

            Cart objCart = new Cart();
            if (Session["cart"] != null)
                objCart = (Cart)Session["cart"];
            objCart.AddToCart(sp);
            Session["cart"] = objCart;
        }
    }
}
